import * as echarts from 'echarts';
import { useEffect } from 'react';

const BarChart = () => {
        
    useEffect(()=>{

        var chartDom = document.getElementById('bar-chart');
        var myChart = echarts.init(chartDom,'dark');
        var option;
        window.addEventListener("resize", () => {
            myChart.resize();
          });
        option = {
            backgroundColor:'',
          tooltip: {
            trigger: 'axis',
            axisPointer: {
              type: 'shadow'
            }
          },
          legend: {},
          grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
          },
          xAxis: [
            {
              type: 'category',
              data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
            }
          ],
          yAxis: [
            {
              type: 'value'
            }
          ],
          series: [
            {
              name: '外地游客',
              type: 'bar',
              barWidth: 20,
              stack: 'Search Engine',
              emphasis: {
                focus: 'series'
              },
              data: [620, 732, 701, 734, 1090, 1130, 1120]
            },
            {
              name: '本地游客',
              type: 'bar',
              stack: 'Search Engine',
              emphasis: {
                focus: 'series'
              },
              data: [120, 132, 101, 134, 290, 230, 220]
            },
            {
              name: '国外游客',
              type: 'bar',
              stack: 'Search Engine',
              emphasis: {
                focus: 'series'
              },
              data: [60, 72, 71, 74, 190, 130, 110]
            },
          ]
        };
        
        option && myChart.setOption(option);
        
    },[])

    return(
        <div id='bar-chart' style={{width:'100%',height:'100%'}}>

        </div>
    )
}
export default BarChart
